package week2

import (
	"bufio"
	"io"
)

func CountLines(r io.Reader) (int, error){
	sc := bufio.NewScanner(r)
	lines := 0
	for sc.Scan(){
		lines++
	}
	//扫描器模式,一定要带上 Error
	return lines, sc.Err()
}
